<?php use_helper('Javascript') ?>
<?php include_stylesheets_for_form($form) ?>
<?php include_javascripts_for_form($form) ?>

<div class="sf_admin_form">
  <?php echo form_tag_for($form, '@operaciones') ?>
    <?php echo $form->renderHiddenFields() ?>

    <?php if ($form->hasGlobalErrors()): ?>
      <?php echo $form->renderGlobalErrors() ?>
    <?php endif; ?>

    <?php foreach ($configuration->getFormFields($form, $form->isNew() ? 'new' : 'edit') as $fieldset => $fields): ?>
      <?php include_partial('operaciones/form_fieldset', array('operaciones' => $operaciones, 'form' => $form, 'fields' => $fields, 'fieldset' => $fieldset)) ?>
    <?php endforeach; ?>
   <?php if($form->isNew()): ?>
    <table>
        <tbody>
        <tr>
            <th><?php echo $formCajaDiaria['cant_inicial']->renderLabel() ?></th><td><?php echo $formCajaDiaria['cant_inicial']->render() ?></td>
            <th><?php echo $formCajaDiaria['cant_existente']->renderLabel() ?></th><td><?php echo $formCajaDiaria['cant_existente']->render() ?></td>
            <th><?php echo $formCajaDiaria['diferencia']->renderLabel() ?></th><td><?php echo $formCajaDiaria['diferencia']->render() ?></td>
            <th><?php echo $formCajaDiaria['cant_final']->renderLabel() ?></th><td id="td_cantidad_final"><?php echo $formCajaDiaria['cant_final']->render() ?></td>
        </tr>
        </tbody>
    </table>

    <?php echo javascript_tag(
            remote_function(array(
                'url' => 'operaciones/getCantidadFinal',
                'update' => 'td_cantidad_final',
                //'with' => "'caja=' + caja_diaria_cant_existente",
            ))); ?>

    <script type="text/javascript">
        jQuery('#operaciones_op_monto').bind('change',function(){
            cant_final = jQuery('#caja_diaria_cant_existente').attr('value') - jQuery('#operaciones_op_monto').attr('value');
            jQuery('#caja_diaria_cant_final').attr('value',cant_final);
        });
    </script>

    <?php /*echo observe_field('operaciones_op_monto',array(
                'url' => 'operaciones/getCantidadFinal',
                'update' => 'td_cantidad_final',
                //'with' => "'caja=' + caja_diaria_cant_existente",
            ));*/ ?>
   <?php endif; ?> 
    <?php //include_partial('operaciones/form_actions', array('operaciones' => $operaciones, 'form' => $form, 'configuration' => $configuration, 'helper' => $helper)) ?>
  
</form>
  
</div>
